/**
 * @(#) DataAttribute.java
 */

package cn.edu.sjtu.se.dslab.component.data;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "data_attribute")
public class DataAttribute implements Serializable {
	private static final long serialVersionUID = 1L;
	/**
	 * 该属性的类型
	 */
	private DomainEntity type;

	private long id;

	private String name;

	
	/**
	 * 该属性对应的序号
	 */
	private int order;
	
	/**
	 * 该属性所占的长度（长度为0，表示全部占用）
	 */
	private int length;
	
	
	/**
	 * 所属的domainEntity
	 */
	private DomainEntity entity;
	
	

	public DataAttribute() {
		super();
		length = 0;//默认表示全部占用
	}

	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "data_entity_id")
	public DomainEntity getEntity() {
		return entity;
	}

	public void setEntity(DomainEntity entity) {
		this.entity = entity;
	}

	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "type_id")
	public DomainEntity getType() {
		return type;
	}

	public void setType(DomainEntity type) {
		this.type = type;
	}


	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	@Column(name = "name", nullable = false, length = 255)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	@Column(name = "order_a", nullable = false)
	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}
	@Column(name = "length_a", nullable = false)
	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

}
